package com.yanqu.road.entity.autodata.specialserver;

import com.alibaba.fastjson.JSONObject;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.autodata.AutoDataObject;

import java.util.*;

@FieldTypeAnnotation(tableName = "t_u_ice_server")
public class IceServerUserData extends AutoDataObject {

    @FieldTypeAnnotation(desc = "用户Id", update = true)
    private long userId;

    @FieldTypeAnnotation(desc = "引导id")
    private int guideId;

    @FieldTypeAnnotation(desc = "饱腹值")
    private int satiation;

    // 温度改为建造数量，客户端那边的，实际字段就不换了，名字换个包装
    @FieldTypeAnnotation(desc = "温度")
    private int temperature;

    @FieldTypeAnnotation(desc = "熔炉熟练度")
    private int stoveExp;

    @FieldTypeAnnotation(desc = "熔炉等级")
    private int stoveLv;

    @FieldTypeAnnotation(desc = "燃烧物")
    private int stoveItem;

    @FieldTypeAnnotation(desc = "任务节点开始时间")
    private long taskStartTime;

    @FieldTypeAnnotation(desc = "任务节点完成时间")
    private long taskFinishTime;

    @FieldTypeAnnotation(desc = "已解锁熔炉燃烧物")
    private Set<Integer> unlockStoveItem = new HashSet<>();

    @FieldTypeAnnotation(desc = "npc数据")
    private List<IceServerNpcData> npcDataList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "寒冬银两")
    private long specialSilver;

    @FieldTypeAnnotation(desc = "寒冬任务完成时间节点（特定任务）")
    private Map<Integer, Long> taskCompleteTimeMap = new HashMap<>();

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setOp(DataStatus.Update);
        }
    }

    public int getGuideId() {
        return guideId;
    }

    public void setGuideId(int guideId) {
        if (this.guideId != guideId) {
            this.guideId = guideId;
            setOp(DataStatus.Update);
        }
    }

    public int getSatiation() {
        return satiation;
    }

    public void setSatiation(int satiation) {
        if (this.satiation != satiation) {
            this.satiation = satiation;
            setOp(DataStatus.Update);
        }
    }

    public int getTemperature() {
        return temperature;
    }

    public void setTemperature(int temperature) {
        if (this.temperature != temperature) {
            this.temperature = temperature;
            setOp(DataStatus.Update);
        }
    }

    public int getStoveExp() {
        return stoveExp;
    }

    public void setStoveExp(int stoveExp) {
        if (this.stoveExp != stoveExp) {
            this.stoveExp = stoveExp;
            setOp(DataStatus.Update);
        }
    }

    public int getStoveLv() {
        return stoveLv;
    }

    public void setStoveLv(int stoveLv) {
        if (this.stoveLv != stoveLv) {
            this.stoveLv = stoveLv;
            setOp(DataStatus.Update);
        }
    }

    public int getStoveItem() {
        return stoveItem;
    }

    public void setStoveItem(int stoveItem) {
        if (this.stoveItem != stoveItem) {
            this.stoveItem = stoveItem;
            setOp(DataStatus.Update);
        }
    }

    public long getTaskStartTime() {
        return taskStartTime;
    }

    public void setTaskStartTime(long taskStartTime) {
        if (this.taskStartTime != taskStartTime) {
            this.taskStartTime = taskStartTime;
            setOp(DataStatus.Update);
        }
    }

    public void setTaskFinishTime(long taskFinishTime) {
        if (this.taskFinishTime != taskFinishTime) {
            this.taskFinishTime = taskFinishTime;
            setOp(DataStatus.Update);
        }
    }

    public long getTaskFinishTime() {
        return taskFinishTime;
    }

    public Set<Integer> getUnlockStoveItem() {
        return unlockStoveItem;
    }

    public void addUnlockStoveItem(int stoveItem) {
        unlockStoveItem.add(stoveItem);
        setOp(DataStatus.Update);
    }

    public void setUnlockStoveItem(Set<Integer> unlockStoveItem) {
        if (unlockStoveItem == null) {
            return;
        }
        this.unlockStoveItem = unlockStoveItem;
        setOp(DataStatus.Update);
    }

    public long getSpecialSilver() {
        return specialSilver;
    }

    public void setSpecialSilver(long specialSilver) {
        if (this.specialSilver != specialSilver) {
            this.specialSilver = specialSilver;
            setOp(DataStatus.Update);
        }
    }

    public Map<Integer, Long> getTaskCompleteTimeMap() {
        return taskCompleteTimeMap;
    }

    public void setTaskCompleteTimeMap(Map<Integer, Long> taskCompleteTimeMap) {
        if (taskCompleteTimeMap == null) {
            return;
        }
        this.taskCompleteTimeMap = taskCompleteTimeMap;
        setOp(DataStatus.Update);
    }

    public void addNpcData(IceServerNpcData npcData) {
        if (npcData == null) {
            return;
        }
        npcDataList.add(npcData);
        setOp(DataStatus.Update);
    }

    public List<IceServerNpcData> getNpcDataList() {
        return npcDataList;
    }

    public void setNpcDataList(List<IceServerNpcData> npcDataList) {
        if (npcDataList == null) {
            return;
        }
        List<IceServerNpcData> tempList = new ArrayList<>();
        for (Object obj : npcDataList) {
            if (obj instanceof JSONObject) {
                IceServerNpcData npcData = JSONObject.parseObject(obj.toString(), IceServerNpcData.class);
                tempList.add(npcData);
            } else {
                tempList.add((IceServerNpcData) obj);
            }
        }
        this.npcDataList = tempList;
        setOp(DataStatus.Update);
    }
}
